package com.heima.controller;

import com.heima.exception.CustomException;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/login")
    public Map login(Integer id,String username,String password) throws CustomException {
        if (StringUtils.isEmpty(username)){
            //自定义抛出异常
            throw new CustomException("用户名不能为空");
        }
        //抛出非自定义异常
        int i= 1/0;
        Map map = new HashMap();
        map.put("msg","login ok .. ");
        map.put("data","");
        return map;
    }

}
